package com.fanco.learn_datastruct_leetcode.designpattern.iterator;

import java.util.Iterator;

/**
 * @author qiaowang 2022/2/22
 * 描述
 */
public class ComputerCollege implements Colleage {

    Department[] departments;
    int numberOfDepartment = 0; // 保存当前数组的对象个数

    public ComputerCollege() {
        departments = new Department[5];
        addDepartment("Java专业", "Java专业");
        addDepartment("Php专业", "Php专业");
        addDepartment("大数据专业", "大数据专业");
        addDepartment("前端专业", "前端专业");
    }

    @Override
    public String getName() {
        return "计算机学院";
    }

    @Override
    public void addDepartment(String name, String desc) {
        Department department = new Department(name, desc);
        departments[numberOfDepartment] = department;
        numberOfDepartment += 1;
    }

    @Override
    public Iterator createIterator() {
        return new ComputerColleageIterator(departments);
    }
}
